<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" id="html">
    <head>
        <title></title>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <base href="<?= base_url(1); ?>" />
        <link type="text/css" href="css/main.css?v=<?= $config['version'] ?>" rel="stylesheet" />
        <script src="js/time.js?"></script>
		<script charset="utf-8" src="edit/kindeditor.js"></script>
		<script charset="utf-8" src="edit/lang/zh_CN.js"></script>
		<script charset="utf-8" src="edit/plugins/code/prettify.js"></script>
		
		<script type="text/css">
		.roleclass { color:#fff;}
		.objectclass { color:#fff;}
		</script>
		
        <script type="text/javascript">
            //var i = 0;
            function addp()
            {
            	var i = $(".autocomplete").length;
            	//alert("i = "+i);
                if (i < 4)
                {
                    i++;
                }
                else
                {
                    alert('up to four!');
                    return;
                }
                //alert("i = "+i);
                str = '<p id="p' + i + '">'
                	+'<input type="text" size="39"  placeholder="<?= translate('PLASE_INPUT_ITEM') ?>" '
                		+' name="row[item][]" id="itemid' + i + '" class="autocomplete" table="type_object" autocomplete="off" >' 
                	+'<input type="text" size="8" placeholder="<?= translate('PLASE_INPUT_AMOUNT') ?>" '
                		+' name="row[amount][]" id="num' + i + '" >'
                	+'<?=translate('MAIL_EQUIPLEVEL')  ?>'
                	+'<select name="row[equiplevel][]" id="equiplevel'+i+'" >'
	                    +'<?php for ($i=0; $i<=30;++$i) { ?>'
	                    	+'<option value="<?=$i ?>"><?=$i ?></option>'
	                    +'<?php }?>'
                    +'</select>'
                	+'</p>';
                //alert(" str = "+str);
                $("#add").append(str);
                autocomplete();

                $("#num"+i).formValidator({empty: false, onshow: '<?= translate('MAIL_TIME_LIMIT_MIN_MAX') ?>'})
                	.inputValidator({type: 'number', min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
                
            }
            function removep()
            {
            	var i = $(".autocomplete").length;
            	//alert("i = "+i);
                if (i > 0)
                {
			$("#p" + i).remove();
                }
	
            }
            function nameaddp()
        	{
        	    //得到当前数组的长度
        	    var i = $(".roleclass").length;
        		//alert(i);
        		var str=' <table width=100%  class="roleclass" id = "role'+i+'"> '+
	                '<tr><td>&nbsp;</td><td><?=translate("PUSH_ROLENAME") ?><input type="text" name="row[reciver_name]['+i+']"  size="25" id="reciver_name'+i+'" />'
	                +'<?=translate("PUSH_ROLEID") ?><input type="text" name="row[reciver_id]['+i+']"  size="25" id="reciver_id'+i+'" />'
	                +'</td></tr>'+
	                '</table>';
        	    //alert(str);	
        	    $("#rolenames").append(str);
        	    //$("#add").after(str);
        	    autocomplete();
        	    //$("#reciver_name"+i).formValidator({empty: false, onshow: '<?= translate('C_NOT_EMPTY') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
        	   
        		getEdit(i)
        		 
        		}
        	function nameremovep()
        	{
        		var i = $(".roleclass").length;
        	    //alert(i);
        	    if (i > 1)
        	    {
            	    i = i - 1;
        	        //alert(i);
        	        $("#role" + i).remove();
        	        //i--;
        	    }
        	}
        </script>
    </head>
    <body>
       <?php include(VIEWPATH . 'common/main_header.php');?>
         <form action="" method="POST" id="rowForm">
         	<table width="100%" border="0" cellspacing="1" cellpadding="0" class="tablegrid tableedit">
                <tr align="left">
                    <th colspan="2" align="left"><?= $title ?></th>
                </tr>
                <tr><td><?= translate('SELECT_AREA') ?>:</td><td>
                
                <select name="row[area]" id = "area" >
	                  	<?php foreach ($arealist as $key=>$value) { ?>
	                    <option value="<?=$key ?>"><?=$key."-".$value['name'] ?></option>
	                    <?php } ?>
	           </select>
                </td></tr>
                
                <tr><<td><?= translate('PUSH_RECEIVER') ?>:</td><td>&nbsp;</td></tr>
                <tr>
                	<td>&nbsp;</td>
                	<td id="rolenames">&nbsp;</td>	                					
                </tr>		
                
                <tr><td>&nbsp;</td><td >
	                    <input type="button" onclick="nameaddp()" value="<?= translate('ADD_ONE') ?>" />
	                    <input type="button" onclick="nameremovep()" value="<?= translate('REMOVE_ONE') ?>" />
                </td></tr> 
                
                <tr><td><?= translate('PUSH_CONTENT') ?>:</td>
                <td>
                <textarea cols="70" rows="13" name="row[content][content]" id="content"></textarea></td></tr> 
                <tr>
      <td><?= translate('FREQUENCE') ?>
        :</td>
      <td><?= $frequence ?>
      </td>
    </tr>
    <tr>
      <td><?= translate('STARTTIME') ?>
        :</td>
      <td><input type="text" name="row[starttime]" id="starttime" size= 25px 
      		value="<?= date("Y-m-d H:i:s") ?>" class="datepicker" showtime="true" /></td>
    </tr>
                <tr><td></td><td>
                
                &nbsp;&nbsp;&nbsp;&nbsp;
                        <input type="submit" value="<?= translate('SUBMIT') ?>" id="submit"/>
                        </td></tr>
            </table>
        </form>
        <script type="text/javascript">
            SG.init("core.form", function() {
                $.formValidator.initConfig({formid: "#rowForm", submitonce: true});
                $("#area_host").formValidator({empty: false, onshow: '<?= translate('PLASE_SELECT') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
                $("#push_name").formValidator({empty: false, onshow: '<?= translate('PLASE_WRITE') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
                $("#content").formValidator({empty: false, onshow: '<?= translate('PLASE_WRITE') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
                $("#frequence").change();
                });
            $("#type,#frequence").change(function() {
                var type = $(this).attr("id");
                var val = $(this).val();
                $("tr." + type).hide();
                $("." + val).show();
                $("tr." + type + " td input,tr." + type + " td textarea").unFormValidator(true);
                $("tr." + val + " td input,tr." + val + " td textarea").unFormValidator(false);
            });
        </script>
    </body>
</html>
